package com.utils;

import java.util.List;
import java.util.Map;

public class DicUtil {

	/**
	 *	跟根据数据字典名字获取对应的编码
	 */
	public static String compare(List list, String str) {
		String str1 = "";
		try {
			for (int i = 0; i < list.size(); i++) {
				List newList = (List) list.get(i);
				if (!(str.equals(newList.get(1).toString()))) {
					str1 = "";
				} else {
					str1 = (String) newList.get(0);
					break;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str1;
	}
	
	
	/**
	 *	跟根据数据字典名字获取对应的编码
	 */
	public static String compare2(List<Map<String, Object>> list, String str) {
		String str1 = "";
		try {
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> newMap =  (Map<String, Object>) list.get(i);
				if(newMap.get("name").toString().contains(str)){
					str1 = newMap.get("code").toString();
					break;
				}else{
					str1 = "";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return str1;
	}
	
}
